var userH={
    list:function (pageIndex) {
        $("#mlist tbody").html("");
        ajaxH.get(urlH.shopuser.list(pageIndex),function (data) {
            var html='';
            if(data.flag=="success"){
                if(data.data.length>0){
                    for(i=0;i<data.data.length;i++){
                        var m=data.data[i];
                        var tr= $('<tr onMouseOver="onTR(this,1)" onMouseOut="onTR(this,0)" class="tr0" bgcolor="#FFFFFF" onClick="clickTR(this)" onDblClick="dbClickTR(this)"><td class="td0"></td><td class="tdm"></td><td class="tdl"></td><td class="tdm"></td><td class="tdm"></td><td class="tdm"></td><td class="tdm"></td></tr>');
                        tr.children().eq(0).html($('<input id="'+m.id+'" type="checkbox" name="pmuser_id" />'));
                        tr.children().eq(1).text(m.id);
                        tr.children().eq(2).text(m.realName);
                        tr.children().eq(3).text(m.mobile);
                        tr.children().eq(4).text(m.username);
                        tr.children().eq(5).text(m.createdOn);
                        tr.children().eq(6).text('已开通');

                        $("#mlist tbody:eq(0)").append(tr);
                    }
                    // $("#mlist tbody").html(html);
                }else{
                    $("#mlist tbody:eq(1)").append($('<tr bgcolor="#FFFFFF"><td colspan="11" id="empty">没有相关记录</td></tr>'));
                }
                intiPage(data.pageTotal,pageIndex,userH.list);
            }else{

            }
        },"json");
    },
    user_add:function(userinfo){
        ajaxH.post(urlH.shopuser.useradd(),userinfo,function (data) {
            alert("保存成功");
        })
    },
    user_shop_add:function(){

    },
    getshoplist:function (pageIndex ,userid,usertype) {
        $("#mlist tbody").html("");
        ajaxH.get(urlH.shopuser.shoplist(pageIndex,userid,usertype),function (data) {
            var html='';
            if(data.flag=="success"){
                if(data.data.length>0){
                    for(i=0;i<data.data.length;i++){
                        var m=data.data[i];
                        var tr= $('<tr onMouseOver="onTR(this,1)" onMouseOut="onTR(this,0)" class="tr0" bgcolor="#FFFFFF" onClick="clickTR(this)" onDblClick="dbClickTR(this)"><td class="td0"></td><td class="tdm"></td><td class="tdl"></td><td class="tdm"></td><td class="tdm"></td><td class="tdm"></td><td class="tdm"></td><td class="tdm"></td><td class="tdm"></td></tr>');
                        tr.children().eq(0).html($('<input id="'+m.id+'" type="checkbox" name="pmuser_id" />'));
                        tr.children().eq(1).text(m.id);
                        var a=$('<a style="float:left;margin-left:5px;" href="myshop_view.shtml?id='+m.id+'" target="_blank"></a>');
                        a.text(m.shopaccount);
                        tr.children().eq(2).append(a);
                        tr.children().eq(3).text(m.shopname);
                        tr.children().eq(4).text(m.dealdays);
                        tr.children().eq(5).text(m.ratio);
                        tr.children().eq(6).text(m.loginname);
                        debugger;

                        var stausdesc="";
                        switch(m.shopstatus){
                            case 1:{
                                stausdesc="已开通";break;
                            }
                        }
                        tr.children().eq(7).text(stausdesc);
                        $("#mlist tbody:eq(0)").append(tr);
                    }
                    // $("#mlist tbody").html(html);
                }else{
                    $("#mlist tbody:eq(1)").append($('<tr bgcolor="#FFFFFF"><td colspan="11" id="empty">没有相关记录</td></tr>'));
                }
                intiPage(data.pageTotal,pageIndex,userH.getshoplist);
            }else{

            }
        },"json");
    },
    getshopdetail:function (id) {
        ajaxH.get(urlH.shopuser.shopdetail(id),function (data) {
            var html='';

            $("#mlist tbody").html("");
            if(data.flag=="success"){
                $("#shopid").html(data.shop.id);
                $("#shopname").html(data.shop.shopname);
                $("#shopid").html(data.shop.id);
                $("#userCreate").html(fmtDate(data.shop.created_on));
                $("#real_name").html(data.shop.real_name);

                var stausdesc="";
                switch(data.shop.shopstatus){
                    case 1:{
                        stausdesc="已开通";break;
                    }
                }
                $("#shopstatus").html(stausdesc);

                //编辑属性
                $("#shop").html(data.shop.shopname);
                $("#loginname").val(data.shop.loginname);
                $("#shopcode").val(data.shop.shopcode);
                $("#visitcode").val(data.shop.visitcode);
                $("#shopkey").val(data.shop.shopkey);
                $("#dealdays").val(data.shop.dealdays);
                $("#ratio").val(data.shop.ratio);
                $("#openaccount").val(data.shop.openaccount);
                $("input:radio[name=codetype]").find().attr("checked",true);

                $(":radio[name='codetype'][value='" + data.shop.codetype + "']").prop("checked", "checked");
                if(data.opClass.length>0){
                    for(i=0;i<data.opClass.length;i++){
                        var m=data.opClass[i];
                        var tr= $('<tr onMouseOver="onTR(this,1)" onMouseOut="onTR(this,0)" class="tr0" bgcolor="#FFFFFF" onClick="clickTR(this)" onDblClick="dbClickTR(this)"><td class="td0"></td><td class="tdm"></td><td class="tdl"></td><td class="tdm"></td><td class="tdm"></td><td class="tdm"></td><td class="tdm"></td><td class="tdm"></td><td class="tdm"></td></tr>');
                        tr.children().eq(0).html($('<input id="'+m.id+'" type="checkbox" name="opclass" />'));
                        //tr.children().eq(1).text(m.id);
                        var a=$('<a style="float:left;margin-left:5px;" onClick="myshopSet('+m.id+')" target="_blank"></a>');
                        a.text(m.productClassName);
                        tr.children().eq(1).append(a);
                        tr.children().eq(2).text(m.titlePre+'/'+m.titleLaster);
                        tr.children().eq(3).text(m.importentNotice);
                        tr.children().eq(4).text(fmtDate(m.createdOn));
                        $("#mlist tbody:eq(0)").append(tr);
                    }
                }else{
                   $("#mlist tbody:eq(1)").append($('<tr bgcolor="#FFFFFF"><td colspan="11" id="empty">没有相关记录</td></tr>'));
                }

            }else{

            }
        },"json");
    },
    delete:function (id) {

    },
    shopclassadd:function(data){
        ajaxH.post(urlH.shopuser.shopclassadd(),data,function (data) {
            if(data==true){
                showWarning(1500,'保存成功',200,60);
                setTimeout("$('.tips').fadeOut(0);",1500)
            }else{
                showWarning(1500,'保存异常',200,60);
                setTimeout("$('.tips').fadeOut(0);",1500)
            }
        });
    },
    getShopClassDetail:function (scid) {
        ajaxH.get(urlH.shopuser.shopclassdetail(scid),function (data) {

            if(data.flag=="success"){
                $("#Designer").val(data.data.designer);
                var CompanyCode=$("#CompanyCode").val(data.data.companyCode);
                $("#Brand").val(data.data.brand);
                $("#TitlePre").val(data.data.titlePre);
                $("#TitleLaster").val(data.data.titleLaster);
                $("#ImportentNotice").val(data.data.importentNotice);
                $("#BulletPoint").val(data.data.bulletPoint);
                $("#KeyWords").val(data.data.keyWords);
                $("#DescriptionPre").val(data.data.descriptionPre);
                $("#DescriptionLaster").val(data.data.descriptionLaster)
                $("#ProductClass").find("option[value='"+data.data.productClassId+"']").attr("selected",true);
                $("#Ratio").val(data.data.ratio);
            }else{

            }
        },"json");
    },
    shopadd:function (data) {
        ajaxH.post(urlH.shopuser.shopadd(),data,function (data) {
            if(data==true){
                showWarning(1500,'保存成功',200,60);
                setTimeout("$('.tips').fadeOut(0);",1500)
            }else{
                showWarning(1500,'保存异常',200,60);
                setTimeout("$('.tips').fadeOut(0);",1500)
            }
        });
    }
}